﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;

namespace SuDu
{
    public class MyProgressBar : ProgressBar //新建一个MyProgressBar类，它继承了ProgressBar的所有属性与方法
    {
        public MyProgressBar()
        {
            this.SetStyle(ControlStyles.UserPaint, true);
        }

        /// <summary>
        /// 对进度条进行操作
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        { 
            //背景色选择
            SolidBrush brush_backColor = new SolidBrush(System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))));
            //在panel内创建一个矩形
            Rectangle bounds = new Rectangle(0, 0, base.Width, base.Height);
            //背景位置，背景颜色更改
            e.Graphics.FillRectangle(brush_backColor, 1, 1, bounds.Width - 2, bounds.Height - 2);

            
            //前景色选择
            SolidBrush brush_frontColor = new SolidBrush(System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(140)))), ((int)(((byte)(183))))));
            //更改“进度条”（矩形）长与宽
            bounds.Height -= 8;
            bounds.Width = ((int)(bounds.Width * (((double)base.Value) / ((double)base.Maximum))) - 8);//是的进度条跟着ProgressBar.Value值变化
            //前景位置，前景颜色更改
            e.Graphics.FillRectangle(brush_frontColor, 4, 4, bounds.Width, bounds.Height);

            

           
        }
    }
}
